# -g 开启gdb的debug调试（生成的二进制文件中包含调试信息）
# -O0 禁用优化（确保调试一致性）
# -Wall 显示所有警告
CFLAGS := -g -O0 -Wall

log:= thirdparty/log/log.c thirdparty/log/log.h
log_test: test/log_test.c $(log)
	gcc $(CFLAGS) $^ -o $@ -Ithirdparty
#	./$@
#	rm $@

cJson:= thirdparty/cjson/cJSON.c thirdparty/cjson/cJSON.h
cjson_test: test/cjson_test.c $(cJson) $(log)
	gcc $^ -o $@ -Ithirdparty
	./$@
	rm $@

app_common:= app/app_common.c app/app_common.h
app_common_test: test/app_common_test.c $(app_common) $(log)
	gcc $^ -o $@ -Iapp -Ithirdparty
	./$@
	rm $@

app_message:= app/app_message.c app/app_message.h
app_message_test: test/app_message_test.c $(app_common) $(log) $(app_message) $(cJson)
	gcc $^ -o $@ -Iapp -Ithirdparty
	./$@
	rm $@

mqtt_test: test/mqtt_test.c
	-$(CC) $^ -o $@ -lpaho-mqtt3c
	-./$@
	-rm $@


app_mqtt:= app/app_mqtt.c app/app_mqtt.h
app_mqtt_test: test/app_mqtt_test.c $(app_mqtt) $(log) 
	gcc $^ -o $@ -Iapp -Ithirdparty -lpaho-mqtt3c
	./$@
	rm $@

app_pool:= app/app_pool.c app/app_pool.h
app_pool_test: test/app_pool_test.c $(app_pool) $(log)
	gcc $^ -o $@ -Iapp -Ithirdparty
	./$@
	rm $@


app_buffer:= app/app_buffer.c app/app_buffer.h
app_buffer_test: test/app_buffer_test.c $(app_buffer) $(log)
	gcc $^ -o $@ -Iapp -Ithirdparty
	./$@
	rm $@


app_bt:= app/app_bt.c app/app_bt.h
app_device:=app/app_device.c app/app_device.h
app_device_test: test/app_device_test.c $(app_device) $(app_bt) $(log) $(app_buffer) $(app_message) $(app_common) $(cJson) $(app_pool) $(app_mqtt) 
	-$(CC) -o $@ $^ -Ithirdparty -Iapp -lpaho-mqtt3c
	-./$@
	-rm $@